from google.appengine.ext import db
from xmw import Thread_Status,ascii_to_datetime

from xmw import tianya
class Thread(db.Model):
    thread_id=db.StringProperty(required=True,default="NA")
    
    title=db.StringProperty()            
    created =db.DateTimeProperty(auto_now_add=True)    
    lst_page_url=db.StringListProperty()
    page_cnt=db.IntegerProperty(required=True,default=0)    # if FORM page,it means form counts
    chrAuthor=db.StringProperty()
    latest_post_date=db.DateTimeProperty(default    =   ascii_to_datetime("1970-01-01 00:00:00"))
    status  = db.StringProperty(required=True,default =Thread_Status.INIT)
    offset  =db.IntegerProperty(default=0)
    
    def to_thread_dict(self):
        dict={
                'thread_id':self.thread_id,
                'created':self.created,
                'lst_page_url':self.lst_page_url,
                'page_cnt':self.page_cnt,
                'chrAuthor':self.chrAuthor,
                'latest_post_date':self.latest_post_date,
                'status':self.status,
                'offset':self.offset,
                #'title':self.title,
                
              }
        return dict
#t=Thread()
t=tianya.TianyaThread()
t.lst_page_url=['http://www.tianya.cn/techforum/content/98/618884.shtml']
page = t.get_first_page()
print page.offset